package com.borazone.extra.launcher;

import javax.tv.xlet.Xlet;
import javax.tv.xlet.XletStateChangeException;


public class XletRuntime {

	Xlet xlet = null;
	Class loadedXlet = null;
	
	XletRuntime( String classname ) {
		
		try {
			
			
			
			
			
			loadedXlet = ClassLoader.getSystemClassLoader().loadClass(classname);
			xlet = (Xlet) loadedXlet.newInstance();
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		
			
	}
	
	public void initXlet() {
		try {
			xlet.initXlet(null);
		} catch (XletStateChangeException e) {
			e.printStackTrace();
		}
	}
	
	public void startXlet() {
		try {
			xlet.startXlet();
		} catch (XletStateChangeException e) {
			e.printStackTrace();
		}
	}
	
	public void pauseXlet() {
		xlet.pauseXlet();
	}
	
	public void destroyXlet() {
		try {
			xlet.destroyXlet(true);
		} catch (XletStateChangeException e) {
			e.printStackTrace();
		}
	}
	
}
